// MyFamily - XML based genealogy program.
// Copyright (C) 2006  Doug Swisher
// See the file COPYING.txt for license details.

using System;
using System.Windows.Forms;
using System.Diagnostics;

using DataModel;


namespace CommonGui
{
    public partial class SaveResultsDialog : Form
    {
        private SaveResults saveResults;

        public SaveResultsDialog(SaveResults saveResults)
        {
            this.saveResults = saveResults;

            InitializeComponent();
        }

        private void SaveResultsDialog_Load(object sender, EventArgs e)
        {
            this.OutputFileTextBox.Text = this.saveResults.OutputFileInfo.FullName;

            this.WarningCountTextBox.Text = this.saveResults.WarningCount.ToString();

            foreach (string message in saveResults.Messages)
            {
                this.MessagesTextBox.AppendText(message + "\r\n");
            }
        }

        private void ViewOutputButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                Process.Start(this.saveResults.OutputFileInfo.FullName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "GEDCOM view launch threw an exception");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
    }
}